﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace _2DGame
{
    public class HUD
    {
        Player myPlayer;        // Who the HUD belongs to.

        Vector2 HPposition;       // Position on the screen that the HUD will be displayed.
        Vector2 SPposition;
        Vector2 missilePosition;

        /// <summary>
        /// Constructor?
        /// </summary>
        public HUD(Player MyPlayer)
        {
            myPlayer = MyPlayer;
            HPposition = new Vector2(10.0f, 10.0f);
            SPposition = new Vector2(10.0f, 25.0f);
            missilePosition = new Vector2(10.0f, 50.0f);
        }


        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

        }


        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Draw(GameTime gameTime)
        {

            string HitPointsString = "";
            string ShieldString = "";
            String missilesString = "";
            Color HPColor = Color.White;
            Color SPColor = Color.White;
            Color missileColor = Color.White;

            if (myPlayer.MyShip != null)
            {
                float HP = (float)Math.Ceiling(myPlayer.MyShip.CurrentHullPoints);
                float SP = (float)Math.Ceiling(myPlayer.MyShip.CurrentShieldPoints);

                HitPointsString = "Current Hull:" + HP.ToString("00");
                ShieldString = "Current Shield:" + SP.ToString("00");
                missilesString = "Missiles:" + myPlayer.MyShip.NumMissiles.ToString();

                if (myPlayer.MyShip.CurrentHullPoints < 3.0f)
                {
                    HPColor = Color.Orange;
                }
                if (myPlayer.MyShip.CurrentShieldPoints < 3.0f)
                {
                    SPColor = Color.Orange;
                }

            }
            else
            {
                HitPointsString = "YOU ARE DEAD!";
            }

            Resources.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            // The most basic version of drawstring there is, in an attempt to get it to work!
            Resources.SpriteBatch.DrawString(Resources.Font, HitPointsString, HPposition, HPColor);
            Resources.SpriteBatch.DrawString(Resources.Font, ShieldString, SPposition, SPColor);
            Resources.SpriteBatch.DrawString(Resources.Font, missilesString, missilePosition, missileColor);

            Resources.SpriteBatch.End();


        }


    }
}
